package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.PopupWindow;

public class PopupWindowActivity extends AppCompatActivity {

    private String TAG="leo";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_popup_window);
    }

    public void leoClick(View view) {
        View popView = getLayoutInflater().inflate(R.layout.dialog_view,null);
        Button btn1 = popView.findViewById(R.id.PupBtn1);
        Button btn2 = popView.findViewById(R.id.PupBtn2);
        Button btn3 = popView.findViewById(R.id.PupBtn3);
        PopupWindow popupWindow = new PopupWindow(popView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                popupWindow.setFocusable(true);
                popupWindow.setBackgroundDrawable(getResources().getDrawable(R.drawable.ic_launcher_background));
                popupWindow.showAsDropDown(view,view.getWidth(),0);
      btn1.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Log.e(TAG, "onClick: btn1");
              popupWindow.dismiss();
          }
      });
        btn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.e(TAG, "onClick: btn2");
                popupWindow.dismiss();
            }
        });
        btn3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.e(TAG, "onClick: btn3");
                popupWindow.dismiss();
            }
        });
    }
}